// 用户点赞模型
const { DataTypes } = require("sequelize");
const sequelize = require("../config/sequelize.js");

const UserLike = sequelize.define("user_like", {
  userId: {
    type: DataTypes.INTEGER,
    allowNull: false,
    primaryKey: true,
    field: 'user_id',
    references: {
      model: 'users',
      key: 'id'
    }
  },
  animalId: {
    type: DataTypes.INTEGER,
    allowNull: false,
    primaryKey: true,
    field: 'animal_id',
    references: {
      model: 'animals',
      key: 'id'
    }
  },
  createdAt: {
    type: DataTypes.DATE,
    allowNull: true
  }
}, {
  tableName: "user_likes",
  timestamps: true,
  indexes: [
    { fields: ['user_id'] },
    { fields: ['animal_id'] }
  ]
});

module.exports = UserLike;